import {_decorator, Component} from 'cc';

const {ccclass, property} = _decorator;

@ccclass('BGController')
export class BGController extends Component {

    start() {
        // paused
    }

    update(deltaTime: number) {
        // 遍历子节点，移动背景
        for (let bgNode of this.node.children) {
            // 每秒移动 50 距离
            bgNode.setPosition(bgNode.position.x, bgNode.position.y - 100 * deltaTime);
            // 当背景移出屏幕时，重置背景的位置
            if (bgNode.position.y < -850) {
                bgNode.setPosition(bgNode.position.x, 852);
            }
        }
    }

}

